﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StaffPage.aspx.cs" Inherits="EvaluationSystem.ConfigurationPages.StaffPage" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var gridCommand = function (command, record) {

            if (command == "Edit") {
                var id = record.data.Id;
                Ext.net.DirectMethods.EditUsers(record.data.Id, record.data.RoleName, record.data.Groups);
            }
            if (command == "Delete") {
                Ext.Msg.confirm('提示', '您确定要删除' + record.data.UserName + '?', function (btn) {
                    if (btn == 'yes') {
                        Ext.net.DirectMethods.DeleteUser(record.data.Id);
                    }
                });
            }
        };

        var getTasks = function (tree) {
            var msg = [],
                selNodes = tree.getChecked();
            Ext.each(selNodes, function (node) {
                if (msg.length > 0) {
                    msg.push(";");
                }

                msg.push(node.text);
            });

            return msg.join("");
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />

    <asp:ObjectDataSource 
            ID="objectDataSource" 
            runat="server" 
            OnSelected="ObjectDataSource_Selected"
            SelectMethod="GetEmployeesFilter" 
            TypeName="EvaluationSystem.ConfigurationPages.StaffPage">
            <SelectParameters>
                <asp:Parameter Name="start" Type="Int32" />
                <asp:Parameter Name="limit" Type="Int32" />
                <asp:Parameter Name="sort" />
                <asp:Parameter Name="dir" />
                <asp:Parameter Name="count" Direction="Output" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>

    <ext:GridPanel ID="gpUsers" 
            runat="server" 
            Title="管理用户" 
          
             Height="500"
            AutoExpandColumn="Id">
            <Store>
                <ext:Store 
                    ID="store" 
                    runat="server" 
                    RemoteSort="true" 
                    DataSourceID="objectDataSource"
                    OnRefreshData="Store_RefreshData">
                    <AutoLoadParams>
                        <ext:Parameter Name="start" Value="0" Mode="Raw" />
                        <ext:Parameter Name="limit" Value="25" Mode="Raw" />
                    </AutoLoadParams>
                    <Reader>
                        <ext:JsonReader IDProperty="Id">
                            <Fields>
                                <ext:RecordField Name="Id" />
                                <ext:RecordField Name="UserName" />
                                <ext:RecordField Name="Groups" />
                                <ext:RecordField Name="RoleName" />
                               
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                 </ext:Store>
            </Store>

            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                   <ext:Column ColumnID="Id" Header="用户Id" Width="60" DataIndex="Id"/>
                    <ext:Column ColumnID="UserName" Header="用户名" Width="160" DataIndex="UserName"/>
                    <ext:Column ColumnID="Groups" Header="组" Width="200" DataIndex="Groups"/>
                    <ext:Column ColumnID="RoleName" Header="角色" Width="160" DataIndex="RoleName"/>
                   
                    <ext:CommandColumn Width="60">
                        <Commands>
                            <ext:GridCommand Icon="Delete" CommandName="Delete">
                                <ToolTip Text="Delete" />
                            </ext:GridCommand>
                            <ext:CommandSeparator />
                            <ext:GridCommand Icon="NoteEdit" CommandName="Edit">
                                <ToolTip Text="Edit" />
                            </ext:GridCommand>
                        </Commands>
                    </ext:CommandColumn>
                </Columns>
            </ColumnModel>

            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
            </SelectionModel>
           <Listeners>
                <Command Handler="gridCommand(command, record);" />
            </Listeners>
             
              <BottomBar>
                <ext:PagingToolbar ID="PagingToolbar" 
                    runat="server" 
                    PageSize="25" 
                    DisplayInfo="true" 
                    DisplayMsg="显示用户 {0} - {1} 共 {2}" 
                    EmptyMsg="没有用户" 
                    />
            </BottomBar>
            <LoadMask ShowMask="true" />
        </ext:GridPanel>  
    </form>
</body>
</html>
